import {ref, Ref, computed, ComputedRef, reactive} from 'vue'
import Data from "../../../../../../public/config/data.json"
interface handleModal {
    (): void;
}
declare type progeressList = Array<{
    label: string
    isActive: boolean
}>
interface marcketParams {
    dialogFormVisible: Ref
    progressArrWithActive: ComputedRef<progeressList>
    openModal: handleModal
}
export default function handleMarcketModal(currentProgress: Ref): marcketParams {
    const dialogFormVisible = ref(false)
    const progressArr = reactive(Data).processMessage
    const progressArrWithActive = computed((): progeressList => {
        const tmpArr = []
        for (let index = 0; index < progressArr.length; index++) {
            const element = progressArr[index].value;
            // 比当前进度小的都是激活状态
            const isActive = (index + 1) <= currentProgress.value
            tmpArr.push({
                label: element,
                isActive
            })
        }
        return tmpArr
    })
    const openModal = () => {
        dialogFormVisible.value = true
    }
    return {
        dialogFormVisible,
        progressArrWithActive,
        openModal
    }
}
